package net.shambolica.jport;

import net.shambolica.jport.runner.JPortNetRunner;
import net.shambolica.jport.runner.DataConnection;
import net.shambolica.jport.exception.InitializationError;

import java.util.Properties;

/**
 * I am a JPort Application.
 * I receive a bunch of Properties for my initialization, and know who my runner is.
 */
public interface JPortApplication {

    /**
     * Initialize and start running.
     * @param initProps Properties to use for initialization.
     * @param mainConnection Provided data connection, already active vs. Erlang VM master.
     * @param runner    Invoking runner. Use this for application-initiated shutdown.
     * @throws InitializationError   For any other initialization error.
     * @return >= 0 (exit status) if application execution is complete,
     * <br/> < 0 if application will invoke runner.exit(..) asynchronously.
     */
    public int start(Properties initProps, DataConnection mainConnection, JPortNetRunner runner)
            throws InitializationError;

}
